package doorwifi.wd.patientsation.peripheral.mainapp.utils;

import android.app.Activity;
import android.content.Context;
import android.os.Looper;
import android.view.WindowManager;
import android.widget.PopupWindow;
import android.widget.Toast;

/**
 * Created by xuhuan on 2017/6/9.
 */

public class UIUtils {

    public static void showToast(final Context mcontext, final String str){
        new Thread(){

            @Override
            public void run() {
                super.run();
                Looper.prepare();
                Toast.makeText(mcontext , str, Toast.LENGTH_SHORT).show();
                Looper.loop();
            }
        }.start();
    }
    //点击popuwindow 背景变色
    public static void setPopuWindowBackground(final Activity activity, PopupWindow mpopupwindow){
        WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
        lp.alpha = 0.5f;
        activity.getWindow().setAttributes(lp);
        mpopupwindow.setOnDismissListener(new PopupWindow.OnDismissListener() {

            @Override
            public void onDismiss() {
                WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
                lp.alpha = 1f;
                activity.getWindow().setAttributes(lp);
            }
        });

    }
}
